{extends file="index.tpl"}
{block name="page-content"}


<script type="text/javascript">
$(document).ready(function()
{
	$(".edit_tr").click(function()
	{
		var ID=$(this).attr('id');
		$("#telco_"+ID).hide();
		$("#detail_"+ID).hide();
		$("#status_"+ID).hide();
		
		$("#telco_input_"+ID).show();
		$("#detail_input_"+ID).show();
		$("#status_input_"+ID).show();
	}).change(function()
	{
		var ID=$(this).attr('id');
		var telco=$("#telco_input_"+ID).val();
		var detail=$("#detail_input_"+ID).val();
		var status=$("#status_input_"+ID).val();
		
		var dataString = 'id='+ ID +'&telco='+telco+'&detail='+detail+'&status='+status;
		
		$("#telco_"+ID).html('<img src="http://thanhphogame.com/admin/view/img/load.gif" />');
		$("#detail_"+ID).html('<img src="http://thanhphogame.com/admin/view/img/load.gif" />');
		$("#status_"+ID).html('<img src="http://thanhphogame.com/admin/view/img/load.gif" />');
				
		
		$.ajax({
			type: "POST",
			url: 'http://thanhphogame.com/admin/controller/process/ajaxEditTableTelcoPromotion.php',
			data: dataString,
			cache: false,
			success: function(html)
			{
				$("#telco_"+ID).html(telco);
				$("#detail_"+ID).html(detail);
				$("#status_"+ID).html(status);
			}
		});
		
	});
	
	$(".editbox").mouseup(function() {
		return false
	});
	
	$(document).mouseup(function(){
		$(".editbox").hide();
		$(".text").show();
	});

});
</script>

{literal}
<style>
	.editbox
	{
		display:none;
	}
	.editbox
	{
		font-size:14px;
		background-color:#ffffcc;
		border:solid 1px #000;
		padding:4px;
	}
	.edit_tr:hover
	{
		background:url(http://thanhphogame.com/admin/view/img/edit.png) right no-repeat #80C8E5;
		cursor:pointer;
	}

</style>
{/literal}
<div class="row-fluid">
    <div class="span12">
        <div class="block">
        	<div class="btn-group" data-toggle="buttons-checkbox">
				<table>
					<tr>
						<td>
							<form method="POST" action="{$WEB_BASE_URL}/index.php?controller=telcoPromotion&action=add">
								<button type="submit" class="btn btn-warring" >Thêm Khuyến Mãi</button>
							</form>
						</td>
						
					</tr>
				</table>
			</div>
            <div class="head dblue">
                <div class="icon"><span class="ico-layout-9"></span></div>
                <h2>Danh Sách Khuyến Mãi</h2>
                <ul class="buttons">
                    <li><a href="#" onClick="source('table_sort_pagination'); return false;">
                        <div class="icon"><span class="ico-info"></span></div>
                    </a></li>
                </ul>
            </div>
            <div class="data-fluid">
                <table class="table lcnp" id="listGame" cellpadding="0" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th width="5%"><input type="checkbox" class="checkall" /></th>
                            <th width="5%">ID</th>
                            <th width="15%">Telco</th>
                            <th width="50%%">Detail</th>
                            <th width="10%">Status</th>
                            <th width="12%" class="TAC">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                   	{if isset($telcoPromotionArr)}
                    {foreach from=$telcoPromotionArr item=telcoPromotion}
                        <tr id="{$telcoPromotion.id}" class="edit_tr">
                            <td><input type="checkbox" name="order[]" value="528" /></td>
                            <td>{$telcoPromotion.id}</td>
                            <td>
                            	<span id="telco_{$telcoPromotion.id}" class="text">
                            		{$telcoPromotion.telco}
                            	</span>
                            	<select name="telco" class="editbox" id="telco_input_{$telcoPromotion.id}" style="display: none;">
									<option value="Viettel" {if $telcoPromotion.telco eq 'Viettel'}Selected{/if}>Viettel</option>
									<option value="MobiFone" {if $telcoPromotion.telco eq 'MobiFone'}Selected{/if}>MobiFone</option>
									<option value="Vinaphone" {if $telcoPromotion.telco eq 'Vinaphone'}Selected{/if}>Vinaphone</option>
								</select>
                            </td>
                            <td>
                            	<span id="detail_{$telcoPromotion.id}" class="text">
	                            		{$telcoPromotion.detail}
                            	</span>
                            	<textarea rows="1" cols="2" class="editbox" id="detail_input_{$telcoPromotion.id}" style="display: none;">{$telcoPromotion.detail}</textarea>   
                            </td>
                            <td>
                            	<span id="status_{$telcoPromotion.id}" class="text">
                            		{$telcoPromotion.status}
                            	</span>
                            	<select name="status" class="editbox" id="status_input_{$telcoPromotion.id}" style="display: none;">
									<option value="1" {if $telcoPromotion.status eq '1'}Selected{/if}>Hiện</option>
									<option value="0" {if $telcoPromotion.status eq '0'}Selected{/if}>Ẩn</option>
								</select>
                            </td>
                            <td>
                                <a href="{$WEB_BASE_URL}/index.php?controller=telcoPromotion&action=list" class="button green">
                                    <div class="icon"><span class="ico-pencil"></span></div>
                                </a>
                                <a href="{$WEB_BASE_URL}/index.php?controller=telcoPromotion&action=delete&id={$telcoPromotion.id}" class="button red" onclick="return confirm('Bạn có muốn xóa tiếp không?')">
                                    <div class="icon"><span class="ico-remove"></span></div>
                                </a>
                            </td>
                        </tr>
                    {/foreach}
                    {/if}
                    </tbody>
                </table>
                
            </div>
        </div>
    </div>
</div>

{/block}
